#!/bin/bash

set -x

. functions.sh
download_file bcsphp-version-lkg /tmp

latest=`cat /tmp/bcsphp-version-lkg`
version=${1:-$latest}

download_file smx-agg-bcs-vagrant.$version.tgz /tmp

tar xpf /tmp/smx-agg-bcs-vagrant.$version.tgz -C /opt/bcs/
mkdir -p /opt/bcs/www/protected/runtime
mkdir -p /opt/bcs/www/assets
chown -R smx:smx /opt/bcs

 su -c 'cd /opt/bcs && make run' - smx
 /opt/bcs/www/protected/yiic migrate --interactive=0

cp vagrant_http_bcs.conf /etc/httpd/conf.d/
/etc/init.d/httpd restart

set +x
